#!/usr/bin/env node

const path = require('path');
const fs = require('fs');
const inquirer = require('inquirer');

inquirer.prompt([
  {
    type: 'list',
    name: 'type',
    message: 'Choose project‘s type: ',
    choices: [
      { name: 'jquery', value: 'jquery' },
      { name: 'bootstrap', value: 'bootstrap' }
    ]
  }
]).then(answers => {
  const type = answers.type;
  const tmplDir = path.join(__dirname, `../${type}-template`);
  const destDir = process.cwd();

  fs.readdir(tmplDir, (err, files) => {
    if (err) throw err;

    files.forEach(file => {
      fs.writeFileSync(path.join(destDir, file));
    })
  })
});